package com.feinno.urcs.group.entity;

import com.feinno.superpojo.SuperPojo;
import com.feinno.superpojo.annotation.Field;
import com.feinno.urcs.types.MobileNo;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.text.ParseException;

/**
 * @author Li.Hongbo <lihongbo@feinno.com>
 */

@XmlRootElement(name = "GroupListInfo")
public class GroupListInfo extends SuperPojo{
	@Field(id=1)
	private String groupUri;
	@Field(id=2)
	private String groupName;
	@Field(id=3)
	@XmlElement(required = true)
	private boolean isCreator;// 是否为群创建者
	@Field(id=4)
	@XmlElement(required = true)
	private boolean isManager;// 是否为群管理员
	@Field(id=5)
	private String conversionId;//群会话的ConversationID

	public GroupListInfo() {
	}

	public GroupListInfo(String groupUri, String groupName, boolean isCreator, boolean isManager, String conversionId) {
		this.groupUri = groupUri;
		this.groupName = groupName;
		this.isCreator = isCreator;
		this.isManager = isManager;
		this.conversionId = conversionId;
	}

	public GroupListInfo(GroupInfo info, MobileNo self) throws ParseException {
		setGroupUri(info.getGroupSipUri().toString());
		setConversionId(info.getConversationId());
		setGroupName(info.getSubject());
		setIsCreator(self.equals(info.getCreator()));
		setIsManager(self.equals(info.getGroupAdmin()));

	}

	@XmlElement(required = true)
	public String getGroupUri() {
		return groupUri;
	}

	public void setGroupUri(String groupUri) {
		this.groupUri = groupUri;
	}

	public String getGroupName() {
		return groupName;
	}

	public void setGroupName(String groupName) {
		this.groupName = groupName;
	}

	public boolean isCreator() {
		return isCreator;
	}

	public void setIsCreator(boolean isCreator) {
		this.isCreator = isCreator;
	}

	public boolean isManager() {
		return isManager;
	}

	public void setIsManager(boolean isManager) {
		this.isManager = isManager;
	}

	@XmlElement(required = true)
	public String getConversionId() {
		return conversionId;
	}

	public void setConversionId(String conversionId) {
		this.conversionId = conversionId;
	}
}
